package com.limao.CacheManager;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.AsyncContext;
import javax.servlet.http.HttpServletResponse;

import com.limao.DBDataClass.AdvDataClass;
import com.limao.DBDataClass.CrowdHomeCommendClass;
import com.limao.DBDataClass.CrowdSysPriceDataClass;
import com.limao.DBDataClass.CrowdUserAuthClass;
import com.limao.DBDataClass.CrowdVRHomeClass;
import com.limao.DBDataClass.HomeColumClass;
import com.limao.DBDataClass.MobileStateDataClass;
import com.limao.DBDataClass.SysSmsDataClass;
import com.limao.Model.LzPluginException;
import com.limao.Model.PublicData;
import com.limao.Model.RecvData;
import com.limao.Tool.CacheClass;

public class AdvInfo {
	
	//新鲜宝 取首页 栏目
	public static Object GET_HomeMenu(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		
		ArrayList<HomeColumClass> homeMenuList=HomeColumManager.getInstance().Load_HomeColum_All();

		List<Object> list= new ArrayList<Object>();
		if(homeMenuList!=null)
			list.addAll(homeMenuList);
		PublicData goods = new PublicData();


		//生成result包给用户
		goods.state = "1";
		goods.m = m + "";
		goods.info = "获取首页 栏目列表成功";
		goods.list=list;
		
		return goods;
		
	}		
	
	//新鲜宝 主页内容 
	public static Object GET_HomeContent(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		List<CrowdHomeCommendClass> columList=CrowdHomeCommendCache.getInstance().Load_CrowdHomeCommend_All();

		List<Object> list= new ArrayList<Object>();
		if(columList!=null)
			list.addAll(columList);
		PublicData goods = new PublicData();


		//生成result包给用户
		goods.state = "1";
		goods.m = m + "";
		goods.info = "获取主页推荐列表成功";
		goods.total=list.size()+"";
		goods.list=list;
		
		return goods;
		
	}
		

	//&新鲜宝	发起众筹之取认证费用系统参数 
	public static Object GET_CompanyAuthRmbParm(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		//取得认证费用系统参数
		float authcompayrmb=CacheClass.getFloatValue(BaseDataCacheManager.getInstance().Load_Param("authcompayrmb"));
		
		PublicData goods = new PublicData();


		//生成result包给用户
		goods.state = "1";
		goods.m = m + "";
		goods.info = "获取系统参数   认证费用  s成功";
		goods.rmb=authcompayrmb+"";

		
		return goods;
		
	}
	
	public static float CompanyAuthRmbParm()
	{
		return CacheClass.getFloatValue(BaseDataCacheManager.getInstance().Load_Param("authcompayrmb"));
	}
	
	
	//新鲜宝  手机通讯录手机注册与否
	public static Object getMobileState(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		
		if (CacheClass.isEmpty(DataObj.mobile)) 
		{
			throw new LzPluginException( "参数不正确");
		}

		List<MobileStateDataClass> list2=CrowdUserAuthCache.getInstance().getMobileState(DataObj.mobile);

		List<Object> list= new ArrayList<Object>();
		list.addAll(list2);
		
		PublicData data =new PublicData();
		data.m =m+"";
		data.state = "1";
		data.info = "成功";
		data.list=list;
		return data;
		
		
	}
	
	//新鲜宝 短信推广文字
	public static Object getMobileMsgtxt(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		
		SysSmsDataClass tmp=SysSmsCacheManagr.getInstance().Load_SysSms(0);
		CrowdUserAuthClass user=CrowdUserAuthCache.getInstance().getUser(CacheClass.getIntValue(DataObj.userid));
		PublicData data =new PublicData();
		data.m =m+"";
		data.state = "1";
		data.info = "成功";
		
		if(tmp==null)
			data.msg=""+" 新鲜宝注册："+user.qrcodeurl;
		else
			data.msg=tmp.msgtxt+" 新鲜宝注册："+user.qrcodeurl;
		return data;

	}	
	//微信分享标题
	public static Object getWxShareTitle(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		PublicData data =new PublicData();
		data.m =m+"";
		data.state = "1";
		data.info = "成功";
		data.msg=SysSmsCacheManagr.getInstance().getWxShareTitle();
		return data;

	}
	
	//微信分享内容
	public static Object getWxShareContent(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
			PublicData data =new PublicData();
			data.m =m+"";
			data.state = "1";
			data.info = "成功";
			data.msg=SysSmsCacheManagr.getInstance().getWxShareContent();
			return data;

	}
	
	//&新鲜宝	应用的欢迎页广告图片
	public static Object resultSYSFaceImage(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		int pos = 0;

		// ArrayList<AdvDataClass> listArry = CacheClass.getSYSAdv_CacheManager().Load_WeclomeAdv(pos);
		String imgurl=sys_AdvCacheManager.getInstance().Load_WeclomeAdv(pos);
		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取欢迎页广告图片成功";
		data.imgurl = imgurl;

		return data;
	}
	
	//&新鲜宝	首页广告
	public static Object resultSysHomeAdv(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		List<AdvDataClass> listArry = sys_AdvCacheManager.getInstance().Load_SysHomeAdv();

		List<Object> list= new ArrayList<Object>();
		list.addAll(listArry);
		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取首页滑动广告列表成功";
		data.list = list;

		return data;
	}	
	
	//&新鲜宝	取价格筛选列表
	public static Object GET_PRICELIST(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		List<CrowdSysPriceDataClass> listArry = CrowdSysPriceCache.getInstance().load_PriceList();

		List<Object> list= new ArrayList<Object>();
		list.addAll(listArry);
		PublicData data = new PublicData();
		data.m = m + "";
		data.state = "1";
		data.info = "取价格筛选列表成功";
		data.list = list;

		return data;
	}	
			
	
	
	
	
	//&新鲜宝	理财首页
	public static Object GET_VRHomeContent(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		CrowdVRHomeClass tmp=CrowdVRHomeCache.getInstance().Load_CrowdVR();

		PublicData goods = new PublicData();
		//生成result包给用户
		goods.state = "1";
		goods.m = m + "";
		goods.info = "获取理财首页成功";
		goods.obj=tmp;
		
		return goods;
		
	}
	
	
	
}
